﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Wildweeds.SSO.Entity;

namespace Wildweeds.SSO.UserManager
{
    public class UserManager
    {
        static List<UserInfo> userList = null;

        static UserManager()
        {
            userList = new List<UserInfo>();

            AddUser(new UserInfo() { UserName = "renli", Password = "renli", CreateDate = new DateTime(2010, 12, 10) });
            AddUser(new UserInfo() { UserName = "anlyren", Password = "anlyren", CreateDate = new DateTime(2009, 6, 11) });
            AddUser(new UserInfo() { UserName = "sdo", Password = "sdo", CreateDate = new DateTime(1999, 1, 1) });
        }

        public static UserInfo GetByUserName(string userName)
        {
            return userList.SingleOrDefault(t => t.UserName == userName);
        }

        public static int GetUserCount()
        {
            return userList.Count;
        }

        public static bool AddUser(UserInfo entity)
        {
            userList.Add(entity);
            return true;
        }
    }
}
